<template>
  <UIForm v-if="item.title === 'API 设置'" class="bg-form p-4 rounded-lg"
    :schemas="item.schemas as unknown as FormSchema<SettingsFormKey>[]" label-placement="left"
    v-model="settings.aiSetting" />
  <UIForm
    v-memo="[settings.aiSetting.value?.[nowProviderFormIndex].API_KEY, settings.aiSetting.value?.[nowProviderFormIndex].API_URL]"
    v-else-if="settings.aiSetting.value?.[nowProviderFormIndex]" class="bg-form p-4 rounded-lg"
    :schemas="item.schemas as unknown as FormSchema<SettingsFormKey>[]" label-placement="left"
    v-model="settings.aiSetting.value[nowProviderFormIndex]" />
</template>
<script setup lang="ts">
defineProps<{
  item: FormProps;
}>();
const { settings } = settingsStore();
const nowProviderFormIndex = computed(() => {
  return settings.aiSetting.value.findIndex(
    (ai) => ai.PROVIDES === settings.aiSetting.nowProviderName
  );
});
</script>
